PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

How do I remove the label on a custom element?

  1. I'm attempting to create a custom type (input type="hidden") field that has some dynamically generated values.

    Using add_action("gform_field_input" ...) I am able to see the generated input; however, it always has a label attached. Is there a simple way to remove the label when !IS_ADMIN for just this one field?

    Posted 12 years ago on Tuesday June 19, 2012 | Permalink
  2. You can hide that specific label via the field ID with CSS. Do you have a link to your form?

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  3. Oh, It's currently just running on a localhost wordpress install. That's simple enough methodology. Just out of curiosity -- no programmatic way to enforce a null label though/ disable label generation?

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  4. Solution:

    public static function gravityCreateInputElement ($input, $field, $value,
                $lead_id, $form_id)
        {
            if ($field["type"] == "myType") {
                if (IS_ADMIN) {
    
                    $content = "<h3 class='subsection_title'>Custom Widget</h3>";
                } else {
                    $field['cssClass'] = "hidden";
                    $formId = $form_id;
                    $fieldId = $field['id'];
                    $content = "<style type='text/css'> #field_" . $formId . "_" .
                             $fieldId .
                             " { display: none;}</style><input type='hidden' name='myType' value='' />";
                }
    
                return $content;
            }
        }
    Posted 12 years ago on Wednesday June 20, 2012 | Permalink
  5. Nice, thanks for posting!

    Posted 12 years ago on Wednesday June 20, 2012 | Permalink

This topic has been resolved and has been closed to new replies.