How to conditionally hide input in Create and Edit in SimpleForm?
See original GitHub issueI use <SelectInput />
in <Create />
and <Edit />
.
<SelectInput source="type" choices={[
{id: 0, name: 'Type0'},
{id: 1, name: 'Type1'},
]}/>
I need to conditionally hide/display some <TextInput />
in <SimpleForm />
when user choosing Type1. This is because for Type1 additional field is used, for Type0 it even don’t need to be passed to restAPI. How to realize it in the code?
<SimpleForm>
<DisabledInput source="id"/>
<SelectInput source="type" choices={[
{id: 0, name: 'Variable'},
{id: 1, name: 'Constant'},
]}/>
{CONDITION_TO_BE_WRITTEN_AND_NOT_BUGGY && <TextInput source="somevalue" />}
</SimpleForm>
Thank you in advance!
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Hiding/Showing Fields Based On Radio Selection With ...
1 Answer 1 ... Try this. $('input[name="post[is_revision"]').change(function() { var selected = $('input:checked[name="post[is_revision]"]').val ...
Read more >Use JavaScript to Hide or Show a Portion of a Form - YouTube
[HTML] Show/ Hide Form Elements Using JavaScript [HD] · PDF Form Field Scripting Basics · The jQuery Hide, Show, and Toggle Functions ·...
Read more >Conditionally Hide/Show Field on Custom Edit Form
In my SP 2016 environment, I have a custom Edit form containing a field that should be hidden until certain conditions are met....
Read more >heartcombo/simple_form: Forms made easy for Rails ... - GitHub
Basically it's a stack of components that are invoked to create a complete html input for you, which by default contains label, hints,...
Read more >Working with Forms in React - SitePoint
Learn the basics of using forms in React: how to allow users to add or edit info, and how to work with input...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For future googlers: https://stackoverflow.com/a/42816296
@fzaninotto Maybe it’s nice to add the link to the answer next time. You’re 100% right about closing this issue, but I think it’s more useful for people like me, finding these issues. 😃
As to the rest of the people, maybe add a link to the stackoverflow question yourselves when this happens, so we have a nice archive.
@djhi is part of the core team, and I concur. This is not a bug.
Please do your homework, and you’ll see that this question has already been answered in Stack Overflow, and that there is nothing in admin-on-rest preventing it.