⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Required property "Temporary false" for n_n relation



lherlaar
  • profile picture
  • Member

Posted 04 May 2012 - 23:47 PM

Hi,

I have an n_n relation on my form which I made into a required field. I noticed that the label for this field does not get an asterisk (*) as all the other required fields do. However, the required condition is checked on validation, so it is only a display issue.

I was able to trace this back to this line in the grocery_crud library file:

$field_info->required = false; //Temporary false

When I change this into:

$field_info->required = in_array($field_name,$this->required_fields) ? true : false;

the behavior seems to be as intended (no * in label for non required n_n relation and * in label for required n_n relation). The change is also in line with what happens to the required property for other field types about 20 lines below.

My question: why is the required property set to false for n_n relations? And what is the meaning of the "temporary" comment?

Thanks!

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 04 May 2012 - 23:54 PM

The answer is that when I had created this functionality it was difficult for me to make it required so I had it temporary into false. But to tell you the truth I totally forgot to fix this issue and you are the first person to mention it. I will add it to the known issues so other people also know about this and to remind me to fix this.