E107: limitation for rendering country select in form - type country

Created on 25 Jan 2019  路  7Comments  路  Source: e107inc/e107

Country type is limited against dropdown type. Attributes are not passed further...

$ret = vartrue($parms['pre']).$this->country($key, $value).vartrue($parms['post']);

but there is used 3rd parameter.
public function country($name, $value, $options=array())

Dropdown uses
$ret = vartrue($eloptions['pre']).$this->select($key, $parms, $value, $eloptions).vartrue($eloptions['post']);

Thanks

enhancement

Most helpful comment

@SimSync

in form_handler, line 5787:
https://github.com/e107inc/e107/blob/a8c39dc2b40946a64d7b2cee2ca7d288702959cb/e107_handlers/form_handler.php#L5787

Perhaps this should be:

$ret = vartrue($parms['pre']).$this->country($key, $value, $parms).vartrue($parms['post']);

Adding the $parms as a third attribute to the method, so that the placeholder option/parameter is also passed along.

What do you think?

All 7 comments

@Jimmi08 I'm not sure what exactly you are asking for.
Do you want to limit the country select to a limited set of countries?
e.g. only Germany, Austria, Poland ?
In that case, it would be easier to make a custom country list and use a standard select statement to display them...

@SimSync
Hi, no.
With dropdown field I can use parameters like placeholder, other='' (it uses default attributes). Only with country field those attributes are not used. I needed to add onClick action (with works with dropdown) but with dropdown it's ignored.

2 params here: $this->country($key, $value)
but there should be 3
country($name, $value, $options=array())

But if this is complicated or not imported, it could be closed, I solved it different way already.

country($name, $value, $options) has 3 parameters and you can use all options that are also used with the select() method.
Placeholder can be added via $options['placeholder'] = "whatever";, but i'm not 100% sure if the html select element supports placeholder... ?!?

Edit: Just checked the sourcecode. The placeholder will be rendered as an option with the "placeholder" text and an empty value("").

@Jimmi08 but because this code it's not possible (only 2 are passed futher) , only key and value. This is what I am trying to say:

$ret = vartrue($parms['pre']).$this->country($key, $value).vartrue($parms['post']);

@SimSync

in form_handler, line 5787:
https://github.com/e107inc/e107/blob/a8c39dc2b40946a64d7b2cee2ca7d288702959cb/e107_handlers/form_handler.php#L5787

Perhaps this should be:

$ret = vartrue($parms['pre']).$this->country($key, $value, $parms).vartrue($parms['post']);

Adding the $parms as a third attribute to the method, so that the placeholder option/parameter is also passed along.

What do you think?

@Moc Yes, that would make sense ... 馃槃

Thanks guys.

Was this page helpful?
0 / 5 - 0 ratings