Skip to content

Allow form elements visibility#4

Open
Rodolfocartas wants to merge 3 commits into
dkharrat:masterfrom
Rodolfocartas:master
Open

Allow form elements visibility#4
Rodolfocartas wants to merge 3 commits into
dkharrat:masterfrom
Rodolfocartas:master

Conversation

@Rodolfocartas

Copy link
Copy Markdown

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
Copy Markdown
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

dkharrat commented Aug 4, 2015

Copy link
Copy Markdown
Owner

@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

dneykov commented Jun 23, 2017

Copy link
Copy Markdown

When this PR will be merged?
Thanks.

@dkharrat

dkharrat commented Jun 23, 2017

Copy link
Copy Markdown
Owner

@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

dneykov commented Jun 23, 2017

Copy link
Copy Markdown

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

@dneykov

dneykov commented Jul 7, 2017

Copy link
Copy Markdown

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

3 participants