Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions PhpFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ function add_inputs( $arr ) {
*
* @return string
*/
function build_form( $echo = true ) {
function build_form( $echo = true, $populate = array() ) {

$populate = array_intersect_key($populate, $this->inputs);

$output = '';

Expand Down Expand Up @@ -257,7 +259,6 @@ function build_form( $echo = true ) {

// Iterate through the input queue and add input HTML
foreach ( $this->inputs as $val ) :

$min_max_range = $element = $end = $attr = $field = $label_html = '';

// Automatic population of values using $_REQUEST data
Expand All @@ -269,6 +270,10 @@ function build_form( $echo = true ) {
}
}

else if (isset($populate[$val['name']])) {
$val['value'] = $populate[$val['name']][0];
}

// Automatic population for checkboxes and radios
if (
$val['request_populate'] &&
Expand Down Expand Up @@ -495,7 +500,7 @@ private function _output_classes( $classes ) {

$output = '';


if ( is_array( $classes ) && count( $classes ) > 0 ) {
$output .= ' class="';
foreach ( $classes as $class ) {
Expand All @@ -508,4 +513,4 @@ private function _output_classes( $classes ) {

return $output;
}
}
}