React-admin: How to conditionally hide input in Create and Edit in SimpleForm?

Created on 20 Mar 2017  Â·  9Comments  Â·  Source: marmelab/react-admin

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!

Most helpful comment

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.

All 9 comments

We don't provide support through GitHub issues. If you need advice on using or debugging your own project based on admin-on-rest, please use StackOverflow.

You are not right. This is not a debugging. This is an issue, which could become a feature request etc. Ex. see #372, look-alike issue for <TabbedForm /> which was fixed.

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

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.

I agree with @RWOverdijk . You guys do an amazing job on AOR, but your answers (mostly you @fzaninotto ) around here are really dry and almost always condescending. Except one "support" link inside the Readme file, t's not crystal clear that the support is done on StackOverflow.

Sorry if you feel our tone is too harsh.

As for making explicit that we don’t give support via GitHub issue, we’ve done a lot already (Contibuting.md, issue template), but people don’t read that. They just open an issue.

So for us who work hard on admin-on-rest, every “how to” question somehow feels like either a lack of work from the author, or a total lack of regard for us (we picture people thinking “ok, they say that how to questions should go to StackOIverflow for this repo, but It doesn’t apply to me ”). This may explain our tone - but it doesn’t excuse it.

If you have suggestions about how we should adapt our automated answer to “how to” questions, we’d love to read about that, and improve the answer.

And if you want to give a hand, giving a warm(er) welcome to newcomers, and helping them find the right way to ask questions is a good place to start, and would be greatly appreciated.

.

@fzaninotto I suggest opening a slack community (or gitter channel). If those are in place I'll join and provide support.

https://medium.freecodecamp.org/monitor-stack-overflow-activity-directly-into-slack-dc778913490f this works well with slack. Perhaps an idea?

I don't see how a Slack channel can provide better support than StackOverflow if the core team doesn't hang around in there (which we don't want to do, that's why we delegated the support to StckOverflow). That would result in an empty/unresponsive chat, not the best image for a support channel.

@fzaninotto Perhaps, but there are plenty of communities where the users themselves help each other. I already offered to be there and offer support, too.

I personally don't mind that much. I just think you can get a lot more contributors if you lower the level of entry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marknelissen picture marknelissen  Â·  3Comments

waynebloss picture waynebloss  Â·  3Comments

fzaninotto picture fzaninotto  Â·  3Comments

rkyrychuk picture rkyrychuk  Â·  3Comments

phacks picture phacks  Â·  3Comments