### Steps to reproduce the issue
Create a admin field relation
### Expected result
admin field creation succesful created.
### Actual result
Error: JFormRuleInt has invalid regex

### System information (as much as possible)
- OS Name & Version: MacOS latest
- Joomla Version: 3.9.10
- JCB Version: 2.9.21
- Browser: Firefox latest
### Additional comments
Well at this point I am suspicious that this is a Joomla bug... but I will look a little more. Those who can follow... the error comes from here: line 71 in /libraries/src/Form/FormRule.php because of this: line 158 and 176 of /admin/models/forms/admin_fields_relations.xml
So to do a work around for now... just remove the validate="int" lines from the xml and it should work.
TO fully fix this I need to look a little more 👍
Well at this point I am suspicious that this is a Joomla bug... but I will look a little more. Those who can follow... the error comes from here: [line 71 in /libraries/src/Form/FormRule.php](https://github.com/joomla/joomla-cms/blob/3.9.10/libraries/src/Form/FormRule.php#L71) because of this: [line 158](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/models/forms/admin_fields_relations.xml#L158) and [176]( https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/models/forms/admin_fields_relations.xml#L176) of /admin/models/forms/admin_fields_relations.xml
So to do a work around for now... just remove the `validate="int"` lines from the xml and it should work.
TO fully fix this I need to look a little more :+1:
Ahhh found it... the int validation is not a Joomla class, but a custom JCB class, and it worked before, but not anymore... so I just added it in and will be in the next release. For now add the following code:
/**
* Method to test that an integer value was added.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param Form $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid integer, false otherwise.
*
*/publicfunctiontest(\SimpleXMLElement$element,$value,$group=null,Registry$input=null,Form$form=null){// Check if the field is required.
$required=((string)$element['required']=='true'||(string)$element['required']=='required');// If the value is empty and the field is not required return True.
if(($value===''||$value===null)&&!$required){returntrue;}// now validate the value to be an integer
// we need to validate a string with the integer in it
// since this is how Joomla passes the value to the test method
// so we use type coercion along with is_numeric
returnis_numeric($value)&&is_int(+$value);// if you have a better idea... lets hear it.
}
This should resolve the issue.
Ahhh found it... the int validation is not a Joomla class, but a custom JCB class, and it worked before, but not anymore... so I just added it in and will be in the next release. For now add the following code:
So in [/admin/models/rules/int.php](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/models/rules/int.php) add the following method:
```php
/**
* Method to test that an integer value was added.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param Form $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid integer, false otherwise.
*
*/
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
{
// Check if the field is required.
$required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required');
// If the value is empty and the field is not required return True.
if (($value === '' || $value === null) && ! $required)
{
return true;
}
// now validate the value to be an integer
// we need to validate a string with the integer in it
// since this is how Joomla passes the value to the test method
// so we use type coercion along with is_numeric
return is_numeric($value) && is_int(+$value);
// if you have a better idea... lets hear it.
}
```
This should resolve the issue.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Steps to reproduce the issue
Create a admin field relation
Expected result
admin field creation succesful created.
Actual result
Error: JFormRuleInt has invalid regex
System information (as much as possible)
Additional comments
Seems like an older version of JCB on 3.9.10 gives same error.
Some times things break when other things get fixed... thanks for the heads-up I am on it.
Well at this point I am suspicious that this is a Joomla bug... but I will look a little more. Those who can follow... the error comes from here: line 71 in /libraries/src/Form/FormRule.php because of this: line 158 and 176 of /admin/models/forms/admin_fields_relations.xml
So to do a work around for now... just remove the
validate="int"lines from the xml and it should work.TO fully fix this I need to look a little more 👍
Ahhh found it... the int validation is not a Joomla class, but a custom JCB class, and it worked before, but not anymore... so I just added it in and will be in the next release. For now add the following code:
So in /admin/models/rules/int.php add the following method:
This should resolve the issue.