⚠ 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

setRule not working properly



gcshyam

gcshyam
  • profile picture
  • Member

Posted 29 May 2020 - 15:42 PM

I have a grocerycrud Enterprise licence, I am trying to use following codes, it is not working .

 

1. $crud->setRule('Email','regex','//^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/');

2. $crud->setRules(
                [
                    'fieldName'  => 'Email',
                    'rule'       => 'regex',
                    'parameters' => '//^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/'
                ]
        );

for the second code I got the following error:

h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Illegal string offset 'fieldName'</p>
<p>Filename: State/StateAbstract.php</p>
<p>Line Number: 1488</p>
    <p>Backtrace:</p>
            <p style="margin-left:10px">
            File: C:\xampp\htdocs\ci-grcrud-vanilla\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\StateAbstract.php<br />
            Line: 1488<br />
            Function: _error_handler            </p>
            <p style="margin-left:10px">
            File: C:\xampp\htdocs\ci-grcrud-vanilla\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\State\UpdateState.php<br />
            Line: 50<br />
            Function: getValidationRules            </p>
            <p style="margin-left:10px">
            File: C:\xampp\htdocs\ci-grcrud-vanilla\application\libraries\GroceryCrudEnterprise\grocerycrud\enterprise\src\GroceryCrud\Core\GroceryCrud.php<br />
            Line: 2450<br />
            Function: render            </p>
            <p style="margin-left:10px">
            File: C:\xampp\htdocs\ci-grcrud-vanilla\application\controllers\Examples.php<br />
            Line: 100<br />