How to replace form fields

No comment
on Wednesday 22 August 2018
comments: 0

TEXT FIELD

Before:
function form_text($form_name, $form_size, $form_value, $form_maxlength = FALSE, $form_class = "tbox form-control", $form_readonly = "", $form_tooltip = "", $form_js = "") {
...
	return "\n<input class='".$form_class."' type="text">";
}
Now:
function text($name, $value = '', $maxlength = 80, $options= array()) 
{
...
	return "<input type='".$type."' name="{$name}" value="{$value}">get_attributes($options, $name)." />";
}
replacing:
$f->form_text($pname."_title", "40", $tp->toHTML($fi["title"]), "200", "form-control")
$frm->text($pname."_title", $tp->toHTML($fi["title"]),  "200", 'size=40&class=form-control')
So: 1. rename method name 2. delete 2rd parameter (4th becames 3rd) 3. set former size parameter like size=99 as 4th parameter Options: - if parameter class is not defined, class tbox is used - if bootstrap 3 (not 4) is used, class form-control is used NOTE for me: ALWAYS set class, not let it for core - selectize script is used if you use options 'id' and 'selectize' (then class is emptied) - option 'type' is available (only email, otherwise has value text) - option 'typehead' with value 'users' is marked as removed soon Example with placeholder:
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Textarea

Before;
function form_textarea($form_name, $form_columns, $form_rows, $form_value, $form_js = "", $form_style = "", $form_wrap = "", $form_readonly = "", $form_tooltip = "") {
...
		return "\n<textarea class="tbox form-control">".$form_value."</textarea>";
Now:
function textarea($name, $value, $rows = 10, $cols = 80, $options = array(), $counter = false) {
...
		return "<textarea>get_attributes($options, $name).">{$value}</textarea>".(false !== $counter ? $this->hidden('__'.$name.'autoheight_opt', $counter) : '');
So: - swap 4th and 2nd parameters - everything else move to options - set 6th parameter as true Example:
$frm->form_textarea($pname."_info", "10", "20", $tp->toHTML($fi["info"]), "200", "form-control")
$frm->text($pname."_googlemap",  $tp->toHTML($fi["googlemap"]), "200", "size=40&class=form-control&placeholder=".CUP_INFO_ADDRESS)

Open form

$frm->form-open("post", e_SELF, $pname."_form", "", " class='form-horizontal'")
- rename method - move form name as first parameter - replace 3rd with NULL (in this case e_REQUEST_URI is used)
$frm->open($pname."_form",'post', null, array('class'=>'form-horizontal'))

Checkbox

function form_checkbox($form_name, $form_value, $form_checked = 0, $form_tooltip = "", $form_js = "") {
function checkbox($name, $value, $checked = false, $options = array())

Select

just renaming method select_open option select_close
function form_option($form_option, $form_selected = "", $form_value = "", $form_js = "") {
...
return "\n";
}
function option($option_title, $value, $selected = false, $options = '')
return "";

0 Comments

Latest Downloads

JM Download plugin 1.2
in Category: JM Download plugin

JM Download plugin 1.2

2 weeks ago

Plugin for extending the core Download plugin. Version 1.3 on Github Replaced JM_Download plugin, Latest Releases by Father Barry,  Top Downloads menu by SecretR, AACGC Download Tracker by M@CH!N3 V 
Read more..

JM Download plugin 1.2
JM Core plugin 1.6.0
in Category: e107 plugins

JM Core plugin 1.6.0

1 month ago

The version used on this site. It fixes some core limitation via the plugin, no core changes. Check Readme at first.  Version 1.6.1 on github What is inside? - fix for missing titles in the m 
Read more..

JM Core plugin 1.6.0
ReCaptcha plugin 1.3
in Category: ReCaptcha plugin

ReCaptcha plugin 1.3

1 month ago

No CAPTCHA reCAPTCHA Captcha replacement for e107 v2.2 or higher with shortcodes.  Added shortcodes for replacing contact secure image shortcodes. Possibility to hide it from logged users.
Read more..

ReCaptcha plugin 1.3