Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change value of Option #62

Open
Capt-Zeanie opened this issue Oct 22, 2015 · 2 comments
Open

Change value of Option #62

Capt-Zeanie opened this issue Oct 22, 2015 · 2 comments

Comments

@Capt-Zeanie
Copy link

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

@Art4
Copy link
Contributor

Art4 commented Oct 25, 2015

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/

@Kubo2
Copy link
Contributor

Kubo2 commented Nov 1, 2015

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants