Forum

Thread tagged as: Question, Suggestions, Forms

Can clients add to form fields via the CMS Admin area

Is there a way in which I can allow my client to be able to add to an already existing Perch form the admin area.

For example - I have a form here

Near the bottom of the form you can see there are 4 check-boxes under the Label 'I am interested in' Currently there are 4 options: Specialty One, Specialty Two etc.

I would like my client to be able to add more check-box options on the fly as and when they are needed. Is there anyway of doing this?

Here is my current code for the form:

<perch:form id="form-register-your-interest" class="text-left" method="post" app="perch_forms" role="form">
  <div class="form-group">
    <perch:label for="title">Title: <span class="required">*</span></perch:label>
    <perch:input type="select" options="Mr, Mrs, Miss, Ms, Dr, Pro" class="form-control input-lg" label="Title" id="title" required="true" />
    <perch:error for="title" type="required"><p class="text-red"><small>Please select your Title</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="firstname">First Name: <span class="required">*</span></perch:label>
    <perch:input type="text" class="form-control input-lg" id="name" required="true" label="First Name" placeholder="Enter your First name">
    <perch:error for="firstname" type="required"><p class="text-red"><small>Please enter your First Name</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="surname">Surname: <span class="required">*</span></perch:label>
    <perch:input type="text" class="form-control input-lg" id="name" required="true" label="Surname" placeholder="Enter your Surname">
    <perch:error for="surname" type="required"><p class="text-red"><small>Please enter your Surname</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="profession">Profession: <span class="required">*</span></perch:label>
    <perch:input type="profession" class="form-control input-lg" id="profession" required="true" label="Profession" placeholder="Enter your Profession">
    <perch:error for="profession" type="required"><p class="text-red"><small>Please enter your Profession</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="email">Email Address: <span class="required">*</span></perch:label>
    <perch:input type="email" class="form-control input-lg" id="email" required="true" label="Email" placeholder="Enter your Email">
    <perch:error for="email" type="required"><p class="text-red"><small>Please enter your email</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="telephone">Telephone No:</perch:label>
    <perch:input type="telephone" class="form-control input-lg" id="telephone" label="Email" placeholder="Enter your Telephone No">
  </div>
  <div class="form-group">
    <perch:label for="address-line-1">Address Line 1: <span class="required">*</span></perch:label>
    <perch:input type="adress-line-1" class="form-control input-lg" id="address-line-1" required="true" label="Address Line 1" placeholder="Enter the first line of your address">
    <perch:error for="address-line-1" type="required"><p class="text-red"><small>Please enter the first line of your Address</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="address-line-21">Address Line 2:</perch:label>
    <perch:input type="adress-line-2" class="form-control input-lg" id="address-line-2"  label="Address Line 2" placeholder="Enter the second line of your address">
  </div>
  <div class="form-group">
    <perch:label for="city">City: <span class="required">*</span></perch:label>
    <perch:input type="adress-line-1" class="form-control input-lg" id="city" required="true" label="City" placeholder="Enter your City">
    <perch:error for="city" type="required"><p class="text-red"><small>Please enter your City</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="postcode">Postcode: <span class="required">*</span></perch:label>
    <perch:input type="adress-line-1" class="form-control input-lg" id="postcode" required="true" label="Postcode" placeholder="Enter your Postcode">
    <perch:error for="postcode" type="required"><p class="text-red"><small>Please enter your Postcode</small></p></perch:error>
  </div>
  <div class="form-group">
    <perch:label for="country">Country: <span class="required">*</span></perch:label>
    <perch:input type="select" id="country" class="form-control input-lg" required="true" label="Country" options="Afghanistan, Albania, Algeria, American Samoa, Andorra, Angola, Anguilla, Antarctica, Antigua and Barbuda, Argentina, Armenia, Aruba, Australia, Austria, Azerbaijan, Bahamas, Bahrain, Bangladesh, Barbados, Belarus, Belgium, Belize, Benin, Bermuda, Bhutan, Bolivia, Bosnia and Herzegovina, Botswana, Bouvet Island, Brazil, British Indian Ocean Territory, Brunei Darussalam, Bulgaria, Burkina Faso, Burundi, Cambodia, Cameroon, Canada, Cape Verde, Cayman Islands, Central African Republic, Chad, Chile, China, Christmas Island, Cocos (Keeling) Islands, Colombia, Comoros, Congo, Congo, The Democratic Republic of The, Cook Islands, Costa Rica, Cote D’ivoire, Croatia, Cuba, Cyprus, Czech Republic, Denmark, Djibouti, Dominica, Dominican Republic, Ecuador, Egypt, El Salvador, Equatorial Guinea, Eritrea, Estonia, Ethiopia, Falkland Islands (Malvinas), Faroe Islands, Fiji, Finland, France, French Guiana, French Polynesia, French Southern Territories, Gabon, Gambia, Georgia, Germany, Ghana, Gibraltar, Greece, Greenland, Grenada, Guadeloupe, Guam, Guatemala, Guinea, Guinea-bissau, Guyana, Haiti, Heard Island and Mcdonald Islands, Holy See (Vatican City State), Honduras, Hong Kong, Hungary, Iceland, India, Indonesia, Iran, Islamic Republic of, Iraq, Ireland, Israel, Italy, Jamaica, Japan, Jordan, Kazakhstan, Kenya, Kiribati, Korea, Democratic People’s Republic of, Korea, Republic of, Kuwait, Kyrgyzstan, Lao People’s Democratic Republic, Latvia, Lebanon, Lesotho, Liberia, Libyan Arab Jamahiriya, Liechtenstein, Lithuania, Luxembourg, Macao, Macedonia, The Former Yugoslav Republic of, Madagascar, Malawi, Malaysia, Maldives, Mali, Malta, Marshall Islands, Martinique, Mauritania, Mauritius, Mayotte, Mexico, Micronesia, Federated States of, Moldova, Republic of, Monaco, Mongolia, Montserrat, Morocco, Mozambique, Myanmar, Namibia, Nauru, Nepal, Netherlands, Netherlands Antilles, New Caledonia, New Zealand, Nicaragua, Niger, Nigeria, Niue, Norfolk Island, Northern Mariana Islands, Norway, Oman, Pakistan, Palau, Palestinian Territory, Occupied, Panama, Papua New Guinea, Paraguay, Peru, Philippines, Pitcairn, Poland, Portugal, Puerto Rico, Qatar, Reunion, Romania, Russian Federation, Rwanda, Saint Helena, Saint Kitts and Nevis, Saint Lucia, Saint Pierre and Miquelon, Saint Vincent and The Grenadines, Samoa, San Marino, Sao Tome and Principe, Saudi Arabia, Senegal, Serbia and Montenegro, Seychelles, Sierra Leone, Singapore, Slovakia, Slovenia, Solomon Islands, Somalia, South Africa, South Georgia and The South Sandwich Islands, Spain, Sri Lanka, Sudan, Suriname, Svalbard and Jan Mayen, Swaziland, Sweden, Switzerland, Syrian Arab Republic, Taiwan, Province of China, Tajikistan, Tanzania, United Republic of, Thailand, Timor-leste, Togo, Tokelau, Tonga, Trinidad and Tobago, Tunisia, Turkey, Turkmenistan, Turks and Caicos Islands, Tuvalu, Uganda, Ukraine, United Arab Emirates, United Kingdom, United States, United States Minor Outlying Islands, Uruguay, Uzbekistan, Vanuatu, Venezuela, Viet Nam, Virgin Islands, British, Virgin Islands, U.S., Wallis and Futuna, Western Sahara, Yemen, Zambia, Zimbabwe"/>
    <perch:error for="country" type="required"><p class="text-red"><small>Please select your Country</small></p></perch:error>
  </div>

  <div class="form-group">
    <perch:label for="interested-specialties">I am interested in: <span class="required">*</span></perch:label>
    <div class="checkbox">
      <label>
        <perch:input type="checkbox" id="specialty-1" label="Specialty One" value="Yes"/>
        Specialty One
      </label>
    </div>
    <div class="checkbox">
      <label>
        <perch:input type="checkbox" id="specialty-2" label="Specialty Two" value="Yes"/>
        Specialty Two
      </label>
    </div>
    <div class="checkbox">
      <label>
        <perch:input type="checkbox" id="specialty-3" label="Specialty Three" value="Yes"/>
        Specialty Three
      </label>
    </div>
    <div class="checkbox">
      <label>
        <perch:input type="checkbox" id="specialty-4" label="Specialty Four" value="Yes"/>
        Specialty Four
      </label>
    </div>
  </div>

  <div class="form-group">
    <perch:label for="additional-information">Additional Information:</perch:label>
    <perch:input type="textarea" class="form-control  input-lg" rows="2" id="additional-information" label="Additional Information" placeholder="Enter any additional information here"></perch:textarea>
  </div>
  <perch:input type="submit" id="submit" value="Send" class="btn btn-lg btn-primary" />

  <perch:success>
    <div class="alert alert-success">
      <p><perch:content id="success" type="textarea" label="Thank you message" textile="true" editor="markitup" /></p>
    </div>
  </perch:success>

</perch:form>
Richy Thomas

Richy Thomas 0 points

  • 8 months ago
Drew McLellan

Drew McLellan 2251 points
Perch Support

You can do things like add options to an options attribute, but you can't dynamically add completely new fields.

That would be great Drew.

So you're saying the users wouldn't be able to add new check-boxes - but they are able to add options to something like a select dropdown?

How would I go about doing this?

Drew McLellan

Drew McLellan 2251 points
Perch Support

Yes, that's right.

options="<perch:content id="options" type="text" label="Options" />"

Ahhh got you.

Thanks Drew,

So just to confirm there's no way of allowing clients to be able to add options to fields where a user could select multiple options? e.g. if I needed to list 10 options that can be added/edited by the client and the user and they can select as many as them as they want? It can only be done with single option fields?

Drew McLellan

Drew McLellan 2251 points
Perch Support

Yes, I'm afraid that's right.

Ok thanks Drew.

Drew McLellan said:

options="<perch:content id="options" type="text" label="Options" />"

Hello Drew,

Could you explain where the "Options" region would be created, and then edited in the admin?

I tried adding the region to the page with the form as follows:

// create the "Options" region if it doesn't exist yet
perch_content_create('Options', array(
    'template'   =>'options.html',
    'shared'     =>false,
    'multiple'   =>true,
    'edit-mode'  =>'singlepage',
    'searchable' =>true
));

Within the form template I'm using:

<perch:input type="select" id="options" name="options" options="<perch:content id="options" type="text" label="Options" />" />

I can edit the options in the CMS, but they don't show up in the select dropdown in the form.

Hello Drew,

Any update on this?

You would be best to start your own thread and reference this one as Drew and Rachel have said before that they don't get notifications when other people comment on a thread.