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
Topic CustomHtmlForm - DateField 1976 Views

CustomHtmlForm - DateField

24 February 2012 at 3:15pm

Hello,

i defined DateField like this:

...
      'StartDate' => array(
'type' => 'DateField', /* DateField */
'title' => 'Dátum začatia',
'checkRequirements' => array
(
'isFilledIn' => true,
'isDate' => true
),
'configuration' => array(
            'showcalendar' => true
         )
),
...

but SS throws this error:

[Notice] Object of class OwnProjectContactForm could not be converted to int
GET /vlastni-projekt/

Line 46 in /home/pali/www/projects/idealnidum/public_html/sapphire/forms/TextField.php
Source

37    function Field() {
38       $attributes = array(
39          'type' => 'text',
40          'class' => 'text' . ($this->extraClass() ? $this->extraClass() : ''),
41          'id' => $this->id(),
42          'name' => $this->Name(),
43          'value' => $this->Value(),
44          'tabindex' => $this->getTabIndex(),
45          'maxlength' => ($this->maxLength) ? $this->maxLength : null,
46          'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null
47       );
48       
49       if($this->disabled) $attributes['disabled'] = 'disabled';
50       
51       return $this->createTag('input', $attributes);
52    }

Trace

min(OwnProjectContactForm,30)
Line 46 of TextField.php
TextField->Field()
Line 127 of DateField.php
DateField->Field()
Line 1701 of CustomHtmlForm.php
CustomHtmlForm->CustomHtmlFormFieldByName(StartDate)
call_user_func_array(Array,Array)
Line 369 of ViewableData.php
ViewableData->obj(CustomHtmlFormFieldByName,Array,,1,)
Line 823 of ViewableData.php
ViewableData_Customised->obj(CustomHtmlFormFieldByName,Array,,1)
Line 446 of ViewableData.php
ViewableData->XML_val(CustomHtmlFormFieldByName,Array,1)
Line 56 of .cache.idprojects.templates.Layout.OwnProjectContactForm.ss

Any hint pls.?

Best regards

pali

Re: CustomHtmlForm - DateField

24 February 2012 at 5:30pm Last edited: 24 February 2012 5:33pm

Hello Pali,

you found an error in CustomHtmlForm :)

We just fixed it, you can download the module version 1.3.3 from "http://www.silvercart.org/downloads/silvercart-1-2-1-custom-download/".

The problem occured because the flag "dmyfields" in the configuration section of your definition for "StartDate" was not set.
Without this flag the date field tries to get a maxlength.
Since none was set in the former version the error you got was thrown. We now set the maxlength explicitly in CustomHtmlForm->getFormField for DateFields.

All the best and thanks for your report,
Sascha

Re: CustomHtmlForm - DateField

27 February 2012 at 1:47pm

Hi Sasha,

thank you!

I have new question, but i will start new thread...

Pali

Re: CustomHtmlForm - DateField

28 February 2012 at 2:20pm

hi,

datefield gives no error now, but calendar not in place. I see that JS files are called, but there should be some JS conflict - it doesn't work for me (js validation is broken too).

pali

Re: CustomHtmlForm - DateField

28 February 2012 at 4:02pm

Hello Pali,

in order to get the calendar popup working I had to release a new CustomHtmlForm version.

Please download the version 1.3.4 from "http://www.silvercart.org/downloads/silvercart-1-2-1-custom-download/".

That version will show the calendar popup and use the chosen date. Validation and min/max restrictions won't work for now unfortunately. You'd have to check for those manually in the PHP part of your form.

We'll think about a mechanism of using the field's validation results, but that will take some time.

Regards,
Sascha