This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Change Value Default for placeholder


  1. jdevelopia
    Member

    Hi guys

    How I can change the "value" for "placeholder"?

    When I put a "Default Value" in one of my field-forms I see this code:
    <input id="element_1" class="element text medium" type="text" value="Default Value" name="element_1"> how I can changes this by:
    <input id="element_1" class="element text medium" type="text" placeholder="Default Value" name="element_1">

    Thanks a lot!

    Posted 11 years ago #
  2. yuniar

    You can edit the "includes/view-functions.php" file. There are many places you need to adjust though.
    Basically you need to find this code:

    value="{$element->default_value}"

    and change it to become:

    placeholder="{$element->default_value}"

    MachForm Founder

    Posted 11 years ago #
  3. jdevelopia
    Member

    Great!!! I have it!!! thanks thanks a lot Yuniar!

    big hug!!

    Posted 11 years ago #
  4. jdevelopia
    Member

    hi again!

    When I put some text in Defalut Value in a Field Type "Paragraph Text" the placeholder doesn´t works.

    What I need to change?

    Thanks a lot!!!!

    Posted 11 years ago #
  5. jdevelopia
    Member

    I can´t find the function to change the Default Value into the Field Type "Paragraph Text".

    Help!! ;)

    Thanks a lot!

    Posted 11 years ago #
  6. jdevelopia
    Member

    I think I change the line 258 of view-functions

    $element_markup = <<<EOT
    		<li id="li_{$element->id}" {$li_class}>
    		<label class="description" for="element_{$element->id}">{$element->title} {$span_required}</label>
    		<div>
    			<textarea id="element_{$element->id}" name="element_{$element->id}" class="element textarea {$element->size}" rows="8" cols="90" {$input_handler}>{$element->default_value}</textarea>
    			{$range_limit_markup}
    		</div>{$guidelines} {$error_message}
    		</li>
    EOT;
    
    		return $element_markup;
    	}

    but i can´t do it successfull!

    Posted 11 years ago #
  7. yuniar

    I'm afraid the paragraph field is a bit more complicated and you can't simply change the attribute to "placeholder" without affecting the whole functionality. Sorry. I don't have a workaround for this yet.


    MachForm Founder

    Posted 11 years ago #
  8. jdevelopia
    Member

    thanks a lot Yunair, don´t worry I understand perfectly the reason.

    Again, thanks a lot.

    Posted 11 years ago #
  9. burkecom
    Member

    Has there been any progress with creating a placeholder section so we dont have to change this per machform?

    Posted 10 years ago #
  10. ChessMan
    Member

    @burkecom - great question - bump.

    Also, paragraph replace would be awesome.

    You can edit MF3.5 "includes/view-functions.php" file.

    line # 144
    line # 732
    line # 779
    line # 960
    line # 2727

    value="{$element->default_value}"

    WITH

    placeholder="{$element->default_value}"

    as Yuniar mentioned above

    Posted 10 years ago #
  11. yuniar

    Just a note for anyone doing this modification, make sure not to replace your field's label completely with placeholders as it might reduce the usability of your form. A good read on this:

    http://www.nngroup.com/articles/form-design-placeholders/


    MachForm Founder

    Posted 10 years ago #
  12. adamaliau
    Member

    can we have a new database field to be added to capture the placeholder value and in the code we configure the value as it would be a clean solution for this?

    Posted 10 years ago #
  13. burkecom
    Member

    Yes and when using the place holder, the required fields error section removes the placeholder... as i am using hidden field titles the boxes are highlighted and show blank boxes.

    any way to have placeholders remain?

    Posted 10 years ago #

RSS feed for this topic

Reply