AnsweredAssumed Answered

Is there a way to get the max characters validation value for a field via php?

Question asked by zimazoo on Jan 4, 2018
Latest reply on Jan 8, 2018 by mikebeargie

Is there a way to get the max characters validation value for a field via php?

 

Example:

$fields = $layout->getFields();

 

foreach ($fields as $field){

   $name = $field->getName();

      echo $name.'<br>';

      $result = $field->getResult();

      echo $result.'<br>';

      $style = $field->getType();

      echo $style.'<br>';

      //$maxchar = $field->getMaxCharacters(); --Something like this?

     $rules = $field->getValidationRules();

     print_r(array_values($rules));

 

Outputs to:

name

text

normal

Array ( [0] => 3 ) --Tells me that it has a (3 - FILEMAKER_RULE_MAXCHARACTERS) validation rule but not the 'value' of that rule.

 

I know it exists. print_r(array_values($fields)); shows: ... [_name] => name [_autoEntered] => [_global] => [_maxRepeat] => 1 [_validationMask] => 3 [_validationRules] => Array ( [3] => 1 ) [_result] => text [_type] => normal [_valueList] => [_styleType] => [_maxCharacters] => 200 ) )....

Outcomes