Hi,

I have a field collection field as "main_field_collection_field".
Then have 2 fields in that collection as "field_1" and "field_2".
None of these 3 fields have the Required option checked.

Can I use this module to make the field_2 to be required whenever there is some/any data in field_1 on form submission?

Thanks...

Comments

g089h515r806’s picture

Currently, such issue could be solved by php code validator.

hgurol’s picture

I would be very very happy if you can provide a sample for me. My own php knowledge is almost zero.

Thank you soooo much :)

g089h515r806’s picture

DOCs :http://drupal.org/node/1537028
add php code validator to field_2
sample code :

if(!empty($this->entity->field_1['und'][0]['value'])){
  if(empty($this->value)){
$this->set_error();
}
}
glynster’s picture

I tried this however no luck, the field saves and no error with the textfield is empty.

My setup is a field collection where a user can add a Youtube video or upload a video. The title field needs to be required when either video field is added.

At the moment I have the following setup:

field_video_title
field_video_yt (the php rule above I have added but no luck)
field_video_upload

Is there something I am missing?

nithinkolekar’s picture

Issue summary: View changes

+1
Use case example
Two fields: email id and boolean field "create account" is present. Where email id optional only when "create account" is not checked(true) but should validate to required if boolean value is set to true.

g089h515r806’s picture

It is possible to solve it by adding a condition choice,