-
Notifications
You must be signed in to change notification settings - Fork 920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only show field when another field value is true #527
Comments
There is a "toggle" field just for that, developed by @OwenMelbz in #165 , but is not merged yet I just copied the file proposed (as a custom template) in my own backpack space at resources/views/vendor/backpack/crud/fields/toggle.blade.php and started using it as per Owen instructions, worked great. Usage: (angry is a boolean, why and what_can_we_do are varchar in my example) $this->crud->addField(
[
'label' => 'Are you angry?',
'name' => 'angry',
'type' => 'toggle',
'inline' => true,
'options' => [
0 => 'No',
1 => 'Si'
],
'hide_when' => [
0 => ['why', 'what_can_we_do'],
],
'default' => 0
]);
$this->crud->addField([ 'label' => "Why?", 'type' => 'text', 'name' => 'why', 'both');
$this->crud->addField([ 'label' => "What can we do?", 'type' => 'text', 'name' => 'what_can_we_do', 'both'); |
That's perfect - thanks for your help |
The 'default' setting not working. can someone verify? |
@conandor been working for a while, so most likely a usage problem, can you share the code your using and show us the html its generated (not the whole document, just around the problem area) |
The CRUD:

The HTML:

|
@conandor that didnt work :) |
What method can I use to set the default choice.
|
When adding a new item, i'd like to only show input field 'X' when 'Y' has been selected.
Is this currently possible via the addField() method? Or would the only way be with my own custom javascript injected in?
Thanks!
The text was updated successfully, but these errors were encountered: