Skip to content
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

Allow form elements visibility #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Rodolfocartas
Copy link

I've added the ability to hide elements and sections.

Rodolfo Cartas added 3 commits June 22, 2015 14:00
# Conflicts:
#	nexusdialog/src/main/java/com/github/dkharrat/nexusdialog/controllers/LabeledFieldController.java
@dkharrat
Copy link
Owner

Thanks for your contribution!

I'm reviewing the code changes, but would you please squash the commits into one? I'll add my comments once that's done. Thanks.

@dkharrat
Copy link
Owner

dkharrat commented Aug 4, 2015

@Rodolfocartas any update on your branch?

flibbertigibbet added a commit to flibbertigibbet/NexusDialog that referenced this pull request Jan 13, 2016
…icker

Optionally show time picker dialog after date picker
@dneykov
Copy link

dneykov commented Jun 23, 2017

When this PR will be merged?
Thanks.

@dkharrat
Copy link
Owner

dkharrat commented Jun 23, 2017

@dneykov: It hasn't been merged yet because I haven't received an update from @Rodolfocartas regarding my comments. In any case, it's likely that this PR is out-of-sync with master, so it might have to be re-implemented.

If you need this functionality, one way to get it is to do it on the View object directly. Each FormElement provides access to the its underlying view.

@dneykov
Copy link

dneykov commented Jun 23, 2017

Thanks for your quick response. I will take your suggestions.

@dneykov
Copy link

dneykov commented Jul 7, 2017

@dkharrat When I try to access the view is giving an error:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.github.dkharrat.nexusdialog.FormModel.getValue(java.lang.String)' on a null object reference

Here is what I'm trying:

tmpElement = new EditTextController(this, field.getId(), field.getLabel(), "", field.isRequired());
        
if(field.isHidden()) {
    tmpElement.getView().setVisibility(View.INVISIBLE);
}

return tmpElement;

Thanks

@dkharrat
Copy link
Owner

@dneykov you're getting this crash due to the view not being completely initialized yet. They are initialized once the FormActivity's onCreate method is done. After that, you should be able to access the view of any fields. Something like this should work:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getFormController().getElement(fieldId).getView().setVisibility(View.GONE);
    }

Hope this helps. I think it would be useful to get this hide/show functionality builtin to the library. I'll look into implementing it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants