return array(
'label_setting',
'description_setting',
+ 'prepopulate_field_setting',
//'rules_setting',
//'placeholder_setting',
'input_class_setting',
* @param null|array $entry Null or the Entry Object currently being edited.
*
* @return string
+ */
public function get_field_input( $form, $value = '', $entry = null ) {
- $id = absint( $this->id );
+
$form_id = absint( $form['id'] );
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
- // Prepare the value of the input ID attribute.
- $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id";
-
- $value = esc_attr( $value );
-
- // Get the value of the inputClass property for the current field.
- $inputClass = $this->inputClass;
+ $id = $this->id;
+ $field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id";
+ $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
- // Prepare the input classes.
- $size = $this->size;
- $class_suffix = $is_entry_detail ? '_admin' : '';
- $class = $size . $class_suffix . ' ' . $inputClass;
-
- // Prepare the other input attributes.
- $tabindex = $this->get_tabindex();
- $logic_event = ! $is_form_editor && ! $is_entry_detail ? $this->get_conditional_logic_event( 'keyup' ) : '';
- $placeholder_attribute = $this->get_field_placeholder_attribute();
- $required_attribute = $this->isRequired ? 'aria-required="true"' : '';
- $invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
- $disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
-
- // Prepare the input tag for this field.
- $input = "<input name='input_{$id}' id='{$field_id}' type='text' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>";
-
- return sprintf( "<div class='ginput_container ginput_container_%s'>%s</div>", $this->type, $input );
+ return sprintf( "<div class='ginput_container ginput_container_checkbox'><ul class='gfield_checkbox' id='%s'>%s</ul></div>", esc_attr( $field_id ), $this->get_checkbox_choices( $value, $disabled_text, $form_id ) );
}
- */
}
GF_Fields::register( new Leads_GF_Field() );
// Inject things into gravity forms fields - This intercepts all GravityForms before displaying them
add_filter( 'gform_pre_render', function( $form ) {
-
- $inputs = $choices = array();
foreach ( $form['fields'] as $k => $v ) {
+ $inputs = $choices = array();
if ( $v['type'] == 'leads' ) {
+ // check the inputName to see if it matches a group
$groupData = new GlmDataInterestGroups( $this->wpdb, $this->config );
$groups = $groupData->getList();
- $interestsData = new GlmDataInterests( $this->wpdb, $this->config );
- $interests = $interestsData->getList( null, 'title' );
- //echo '<pre>$interests: ' . print_r($interests, true) . '</pre>';
- if ( $interests ) {
- foreach ( $interests as $interest ) {
- $inputs[] = array(
- 'id' => $v['id'] . '.' . $interest['id'],
- 'label' => $interest['title']
- );
- $choices[] = array(
- 'text' => $interest['title'],
- 'value' => $interest['title'],
- 'isSelected' => false,
- 'price' => ''
- );
+ //echo '<pre>$groups: ' . print_r($groups, true) . '</pre>';
+ //echo '<pre>$v: ' . print_r($v, true) . '</pre>';
+ if ( $groups ) {
+ foreach ( $groups as $group ) {
+ if ( $v['inputName'] == $group['title'] ) {
+ $interestsData = new GlmDataInterests( $this->wpdb, $this->config );
+ $interests = $interestsData->getList(
+ "group_id = " . $group['id'],
+ 'title'
+ );
+ //echo '<pre>$interests: ' . print_r($interests, true) . '</pre>';
+ if ( $interests ) {
+ foreach ( $interests as $interest ) {
+ $inputs[] = array(
+ 'id' => $v['id'] . '.' . $interest['id'],
+ 'label' => $interest['title']
+ );
+ $choices[] = array(
+ 'text' => $interest['title'],
+ 'value' => $interest['title'],
+ 'isSelected' => false,
+ 'price' => ''
+ );
+ }
+ }
+ $form['fields'][$k]['inputs'] = $inputs;
+ $form['fields'][$k]['choices'] = $choices;
+ }
}
}
- $form['fields'][$k]['inputs'] = $inputs;
- $form['fields'][$k]['choices'] = $choices;
+
}
}
}
}
// we need to have email field
- if ( !isset( $glm_leads_entry['email'] ) ) {
+ if ( !isset( $glm_leads_entry['email'] ) || !$glm_leads_entry['email'] ) {
return;
}
// create the lead
$result = $this->wpdb->insert(
GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . 'leads', // table
array(
- 'email' => $glm_leads_entry['email']
+ 'email' => $glm_leads_entry['email'],
+ 'created' => $entry['date_created'],
), // data
- array( '%s' ) // data format
+ array( '%s', '%s' ) // data format
);
if ( $result === false ) {
die( 'lead error given' );