Skip to content

Instantly share code, notes, and snippets.

@mjamilasfihani
Last active June 8, 2020 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjamilasfihani/63e21f8a06f686415877e4f683e7e1ec to your computer and use it in GitHub Desktop.
Save mjamilasfihani/63e21f8a06f686415877e4f683e7e1ec to your computer and use it in GitHub Desktop.
option helper with hidden attribute in CodeIgniter 4
# DONT FORGET TO BACKUP THE ORIGINAL SCRIPT
# NOT EDITED FOR <optgroup ...>...</optgroup>
#
# TESTING WITH CODEIGNITER 4.0.3
#
# open form_helper.php in ../system/Helpers/
# then change : (about line 423)
$form .= '<option value="' . htmlspecialchars($key) . '"'
# with :
$form .= '<option value="' . htmlspecialchars(str_replace('HIDE_', '', $key)) . '"' . (in_array($key, ['HIDE_']) ? ' hidden="" ' : '')
# How to use it
#
# ['HIDE_' => 'Your Position'] --> <option value="" hidden="">Your Position</option>
#
# if you set the array like this
#
# ['HIDE_' => 'Position 1', 'HIDE_' => 'Position 2']
#
# it will show 'Position 2' directly, this is bug? you can say yes or no.
# I think the hidden option without value worked as PLACEHOLDER, so I say it's not a bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment