Jump to content


BUG: requiredFields doesn't work inside getState()

requiredFields in getState groceryCRUDEnterprise workaround

  • Please log in to reply
No replies to this topic

#1 larasmith

larasmith

    Advanced Member

  • Members
  • PipPipPip
  • 199 posts
  • LocationPhilippines

Posted 16 July 2018 - 07:32 AM

Hello Everyone!

 

I have a crud that has a clone feature.

During cloning, I set some of the cloned fields to read-only because I wanted to make the user see what he is currently cloning.

Here is the current code:

$ff = ['gr_SemId', 'gr_AY', 'gr_Name', 'gr_Flooring', 'gr_Ceiling'];
$crud->requiredFields($ff);

$crud->setClone();
$crud->readOnlyCloneFields(['gr_Name']);

 

 

It does what it needs to do but during Save, It says: "Remark is required". I believe that read-only fields should be automatically excluded in the required fields.

 

I did try to make a workaround by using getState:

$state = $crud->getState();

if ($state == 'Insert') { 
$crud->requiredFields(['gr_Flooring']); 
} else if ($state == 'Update') { 
$crud->requiredFields(['gr_Ceiling']); 
}

 

but nothing happens. It seems that it doesn't work. I also tried getting the actual state and using it:

 

$state = $crud->getState();
if ($state == 'CloneForm') {
$crud->requiredFields(['gr_Flooring']);
} else if ($state == 'EditForm') {
$crud->requiredFields(['gr_Ceiling']);
}

still no luck. I hope this bug gets fixed on the next release.

 

Any known workarounds for this one?

Your help is highly appreciated. Thanks!







Also tagged with one or more of these keywords: requiredFields in getState, groceryCRUDEnterprise, workaround

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users