question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to conditionally hide input in Create and Edit in SimpleForm?

See original GitHub issue

I 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:closed
  • Created 7 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
RWOverdijkcommented, Oct 3, 2017

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.

6reactions
fzaninottocommented, Mar 20, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found