We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help needed getting date picker FieldFrame fieldtype to work in FF Matrix

Development and Programming

metadaptive's avatar
metadaptive
96 posts
16 years ago
metadaptive's avatar metadaptive

Hi cwcrawley, I’m afraid I’ve run out of time to spend on this at the moment - am planning on picking it up again once 2.0 is released next month (along with an updated version of the fieldframe api).

In the meantime I’d guess that you need to make sure that each cell in your matrix has a unique ID value (as opposed to each row, which IIRC is what the hack does at the moment).

changing agun’s hack to something like

$td.find('*[id]').each(function() {
                this.id = obj.fieldName+'['+rowIndex+']' + this.name.substring(this.name.indexOf(']')+1);
            });

should add the column index value to the field ID and fix the issue you’re experiencing when you have multiple instances in a single row. I’ve done a very quick (firefox only) test and that seems to do the trick.

please do note though that this really isn’t a released extension - in fact it’s still so alpha it hurts - so I would be extremely cautious about using it in a production environment. At the very least don’t expect to just “grab and go” - it will almost certainly require some tweaking to get it to do what you want it too. Unfortunately it that also means that I can’t offer any guaranty of further support… sorry!

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Buggerit.

I searched for a date picker extension high and low. Din’t find anything. So write my own. Finish it, then about to add it to the forums, and I find this thread.

Typical!

Ho Hum. The problem you’re having is that the JavaScript registers the fields on loading the page, then FF Matrix does a duplication of the row to create a new row - but doesn’t re-call the JavaScript code, so therefore the new date field (on the new row) isn’t linked to the JQuery DatePicker.

One quick fix is to have the JavaScript declaration within the row itself, therefore when it’s duplicated it re-initialises the JQuery DatePicker to the new field.

So instead of using this:

$this->insert_js

You add the code manually after the text field similar to this:

$output .= $SD->text($field_name, $value, array('maxlength' => '30', 'style' => 'datepicker', 'width' => '140px'));
$output .= '[removed]
        $(function() {
            $(".ff-ft .datepicker").datepicker({
                dateFormat: "'.$dateFormat.'"
        });
    });
[removed]';

Edit: The [removed] bits are the script declarations Note: I say similar to this code, as this is copied from my extension, so won’t work “as is” in the extension code in this thread.

There’s still an issue I need to resolve, in that the above displays the datepicker, but alas always populates the first date field. Once I’ve resolved it I’ll post the extension in a separate thread.

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Sorted. Only adds Datepicker to fields that aren’t already initialised, then removes the id (as Matrix duplicates rows, the ID is duplicated which breaks datepicker.

$(".ff-ft .datepicker:not(.hasDatepicker)").removeAttr("id").datepicker({
...
       
metadaptive's avatar
metadaptive
96 posts
16 years ago
metadaptive's avatar metadaptive

Hey Twobelowzero - please do still think about publishing your FT - esp if it’s usable without hacking the FF matrix js as my one depends on. This was never intended to be a “release” thread - it just started as me asking for help to get my version to work.

I’m not planning on doing any further work on my version until 2.0 is out and it’s not really in a usable form at the moment so your version would probably be welcomed…

I’m holding off because I want to add user configurable date formats and styling etc but don’t have time at the mo

       
Peter Lewis's avatar
Peter Lewis
280 posts
16 years ago
Peter Lewis's avatar Peter Lewis

Full details of the extension here.

It has date formatting and themeing built in, so hopefully will be useful to you.

Need to add displaying multiple months next 😊

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.