jBBCode icon indicating copy to clipboard operation
jBBCode copied to clipboard

Change value of Option

Open Capt-Zeanie opened this issue 10 years ago • 2 comments

Is there a way to change the value of the option

Example: I am using SCEditor to create my BBCode. In the editor it has font size which is create a bbcode tag of [size=4]this is font size 4 ie 18px [/size]

Now I want JBBCode to read the 4 and then validate it, and then return the correct font size value in the validation function which is then placed in the html render. eg.

style="font-size:18px">this is font size 4 ie 18px

However I keep getting

style="font-size:4px">this is font size 4 ie 18px

How do I change the option value for a new value.

I am using JBBCode to read this size using... $builder = new CodeDefinitionBuilder('size', '

{param}

'); $builder->setUseOption(true)->setOptionValidator(new \JBBCode\validators\FontValidator()); array_push($this->definitions, $builder->build());

My fontValidator is... public function validate($input) { if (is_numeric($input) && $input <= 7 && $input >= 1) { switch ($input) { case 1: return 10; break; case 2: return 13; break; case 3: return 16; break; case 4: return 18; break; case 5: return 24; break; case 6: return 32; break; case 7: return 48; break; } } else { return 16; } }

Thank you so much if you help me

Capt-Zeanie avatar Oct 22 '15 11:10 Capt-Zeanie

Please paste the code from your FontValidator and how you are using it. Also please use the Markdown Code Syntax: https://guides.github.com/features/mastering-markdown/

Art4 avatar Oct 25 '15 15:10 Art4

@Capt-Zeanie Actually the method InputValidator::validate() is not supposed to return a value which replaces the current value, so all of your attempts result in converting the value to boolean TRUE.

See interface InputValidator

Kubo2 avatar Nov 01 '15 06:11 Kubo2