SilverCart Forum

We moderate this Forum and we're here to help. Have you already run a forum search to check if your problem has already been solved?

You can help us helping you by providing detailed error messages, screenshots and logfile entries.

SebastianRamon

Page: 1 , 2
Topic CustomHtmlForm - multiple forms 4487 Views

CustomHtmlForm - multiple forms

14 February 2012 at 5:08pm

Hello,

when i try to add 3 forms on one page, i get an error:

The requested CustomHtmlForm "ProjectPricingContactForm" is not registered.

My template file looks like this:

   
$InsertCustomHtmlForm(SmallProjectStudyContactForm)
$InsertCustomHtmlForm(ProjectPricingContactForm)
$InsertCustomHtmlForm(OrderProjectDocumentationContactForm)

If i would like to show only one form (any), everything is OK.

Is customHtmlForm module able to show more forms on single page, pls.?

Best regards

Pali

Re: CustomHtmlForm - multiple forms

14 February 2012 at 5:15pm

Hi Pali,

did you register the forms the the controllers init()?

Re: CustomHtmlForm - multiple forms

14 February 2012 at 5:30pm

Hi Roland,

sure. If i call just one (doesnt matter if first, second or third) from this 3 forms, everything is OK and proper form is on place...

pali

Re: CustomHtmlForm - multiple forms

14 February 2012 at 10:27pm

hmmm, it looks like if I register custom HTML forms in different controllers (Page, HomePage, ProjectPage) so i can have multiple forms on one page. But i can have only one form per controller's init()...

This simply doesnt work:

IdProject.php

class IdProject_Controller extends Page_Controller
{
public function init() {
      
$this->registerCustomHtmlForm('OrderProjectDocumentationContactForm', new OrderProjectDocumentationContactForm($this));
      $this->registerCustomHtmlForm('ProjectPricingContactForm', new ProjectPricingContactForm($this));
      $this->registerCustomHtmlForm('SmallProjectStudyContactForm', new SmallProjectStudyContactForm($this));
      
parent::init();   
      
}   

IdProject.ss

   $InsertCustomHtmlForm(ProjectPricingContactForm)
$InsertCustomHtmlForm(SmallProjectStudyContactForm)
$InsertCustomHtmlForm(OrderProjectDocumentationContactForm)

pali

Re: CustomHtmlForm - multiple forms

15 February 2012 at 6:53pm Last edited: 15 February 2012 6:54pm

Hello Pali,

I'll have a closer look at that issue tomorrow and will try to reproduce the behaviour.

What version of Silvercart/CustomHtmlForm are you using?

Regards,
Sascha

Re: CustomHtmlForm - multiple forms

15 February 2012 at 10:29pm

Hi,

.hg_archival.txt says:

repo: 7263ae762b2b944ec11fddc2c54d238bcc46b496
node: 5e6aab2cab16130edb19fa7690e3b9898e83e111
branch: default
latesttag: 1.2
latesttagdistance: 1

SilverStripe is in 2.4.7.

Regards

Pali

Re: CustomHtmlForm - multiple forms

16 February 2012 at 8:42pm Last edited: 16 February 2012 8:46pm

Hi Pali,

just tried to reproduce this issue, but without success - everything works fine with three forms.

Here's what I did:

- Download and install the SilverCart 1.2 full package (http://www.silvercart.org/assets/silvercart_package_silverstripe_full.zip)

- Create class "IdProject.php" in "mysite/code" with the following content:

<?php
class IdProject extends Page {
}
class IdProject_Controller extends Page_Controller {
public function init() {
$this->registerCustomHtmlForm('OrderProjectDocumentationContactForm', new OrderProjectDocumentationContactForm($this));
$this->registerCustomHtmlForm('ProjectPricingContactForm', new ProjectPricingContactForm($this));
$this->registerCustomHtmlForm('SmallProjectStudyContactForm', new SmallProjectStudyContactForm($this));
parent::init();
}
}

- Create template "IdProject.ss" in "mysite/templates/Layout/" with the following content:

$InsertCustomHtmlForm(ProjectPricingContactForm)
$InsertCustomHtmlForm(SmallProjectStudyContactForm)
$InsertCustomHtmlForm(OrderProjectDocumentationContactForm)

- Created the three form classes "ProjectPricingContactForm.php", "SmallProjectStudyContactForm.php" and "OrderProjectDocumentationContactForm.php" in "mysite/code/". They have all the same content, just replace the class names appropriatly:

<?php
class OrderProjectDocumentationContactForm extends SilvercartContactForm {
}

- Create the the form templates "ProjectPricingContactForm.ss", "SmallProjectStudyContactForm.ss" and "OrderProjectDocumentationContactForm.ss" in "mysite/templates/Layout/", again all with the same content (copied from "SilvercartContactForm.ss":

<form class="yform full" $FormAttributes >

$CustomHtmlFormMetadata

<fieldset>
<legend><% _t('SilvercartPage.CONTACT_FORM','contact form') %></legend>
<div class="subcolumns">
<div class="c50l">
<div class="subcl">
$CustomHtmlFormFieldByName(Salutation,CustomHtmlFormFieldSelect)
</div>
</div>
<div class="c50r">
<div class="subcr">
$CustomHtmlFormFieldByName(Email)
</div>
</div>
</div>
<div class="subcolumns">
<div class="c50l">
<div class="subcl">
$CustomHtmlFormFieldByName(FirstName)
</div>
</div>
<div class="c50r">
<div class="subcr">
$CustomHtmlFormFieldByName(Surname)
</div>
</div>
</div>
$CustomHtmlFormFieldByName(Message)
</fieldset>

<div class="actionRow">
<div class="type-button">
<% control Actions %>
$Field
<% end_control %>
</div>
</div>
</form>

- Called "/dev/build/?flush=all"
- Created a page with the page type "IdProject" in the backend

This resulted in three contact forms on the page, each working independantly from the other.

Could you check if your procedure differed somewhere, please?

All the best,
Sascha

EDIT: I saw that our new build script packs the silvercart_order_pdfinvoice module into the full package, which doesn't work with that version. We'll fix that tomorrow, please delete that module if you download the full package before tomorrow.

Re: CustomHtmlForm - multiple forms

17 February 2012 at 9:28am

Good morning,

the silvercart_pdf_invoice module is fixed now in the download packages.

Cheers,
Sascha