str_replace/preg_replace variables to insert value to input

Discussion in 'Templates customization' started by josh_edwards, Mar 3, 2016.

  1. josh_edwards

    josh_edwards aMember Pro Customer

    Joined:
    Sep 2, 2015
    Messages:
    4
    Hi,

    Can anyone provide a little instruction on how to use the str_replace function mentioned in the documentation when customising the sign up form to manipulate the ['html'] element for an email field for example?

    Thanks

    Josh
  2. thehpmc

    thehpmc Member

    Joined:
    Aug 24, 2006
    Messages:
    901
    What are you trying to do exactly?
  3. josh_edwards

    josh_edwards aMember Pro Customer

    Joined:
    Sep 2, 2015
    Messages:
    4
    I am trying to add a value= tag to my inputs and hide the label just for styling purposes.
  4. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,659
    You do not need to touch value attribute because it populated dynamically. I suggest to use CSS style to change view of form instead of alter html layout.

    here is guide for this function
    http://php.net/str_replace

    Here is one example of usage
    PHP:
    $frm['elements']['paysys_id']['htmle'] = str_replace('class="radio"''class="radio additional-class"'$frm['elements']['paysys_id']['htmle']);
    josh_edwards likes this.
  5. josh_edwards

    josh_edwards aMember Pro Customer

    Joined:
    Sep 2, 2015
    Messages:
    4
    That's perfect, thank you! The documentation also mentions on rare occasions needing to split the ['elements'] tag for example to seperate first name and last name fields. Do you happen to know how to achieve this?

    Thanks

    Josh
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,659
    Please go to aMember admin interface
    aMember Cp -> Configuration -> Forms Editor (edit)
    click configure link on Name brick and enable option to display it in two rows.

Share This Page