Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

optional_param in form

Tags:

php

moodle

I have a question about the optional_param function in a form in PHP (version 5.3.14)

After looking over why certain fields were not being saved in a form I have, I realised that this data...

$checkdata = optional_param('items', array(), PARAM_INT)

Only saves up to 996 places (items) from the form (they are select items and there are many)....

Is this a setting or a something I can change? or alternatively something wrong from my end?

Thanks in advance


Solution : A moodle function (platform i am working with)

Thanks Pekka


1 Answers

this function is a moodle function. It gets a parameter from the current page URL.

For an example url:

http://moodle.dev/course/view.php?id=2&items=4

(this is chosen totally arbitrary)

Using this code:

$checkdata = optional_param('items', array(), PARAM_INT)

Will save the "items" value (here it's 4) in $checkdata. If items does not exist in the url it will do $checkdata = array()

like image 148
benomite Avatar answered Mar 01 '26 02:03

benomite



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!