Jump to content

Method TableRow::getUnformatted does not exist or is not callable in this context


Tyssen
 Share

Recommended Posts

I'm trying to compare a date output by a ProFields table field to the current date and have read in the forums that I need to use getUnformatted, but when I do, I get the error in the thread title.

Does comparing dates within tables require special consideration?

Link to comment
Share on other sites

foreach($page->draw as $draw) :
  echo $draw->getUnformatted("date");
endforeach;

With this I get:

Error: Exception: Method TableRow::getUnformatted does not exist or is not callable in this context (in /wire/core/Wire.php line 349)

Link to comment
Share on other sites

You can't do that (getUnformatted is method of Page object, tableRow doesn't have that), but you can do:

$raw = $page->getUnformatted("draw");

var_dump($raw);

But in your case it might be easier just to convert your field into timestamp:

$timestamp = strtotime("pretty much any date format");

  • Like 3
Link to comment
Share on other sites

  • 3 months later...

For anyone wanting to getUnformatted regardless, you can do this:

$page->getUnformatted('dates_table.begin_date');
/* Returns:
 * array(8) {
 * 	[0]=> int(1430863200)
 * 	[1]=> int(1433282400)
 * 	[2]=> int(1434837600)
 * }
 */

Also:

$page->getUnformatted('dates_table.first.begin_date');
// Returns int(1430863200)

$page->getUnformatted('dates_table.last.begin_date');
// Returns int(1434837600)

So you can have your cake and eat it too without having to parse date strings. E. g. you can directly use the inbuilt templating syntax with formatted values, but if, say, you also need a locale aware day name, you can feed the timestamp to strfrtime().

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ngrmm
      I have a page with a table. Each table row has a page-reference field and a checkbox.
      The Page sends emails to all users (page-refrence->email-field) and change the value of the checkbox in a row to 1.
      It works with this:
      <?php // event ID fron url query $eventID = $input->get('eventID','int'); // get event-page $event = $pages->get($eventID); // config $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // email html body ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // make event-page editable $event->of(false); // loop through table and send out emails foreach($event->event_clients_list as $event_table_row) { // get client page $clientPage = $event_table_row->client_name; // get client email $clientEmail = $clientPage->email; // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email $m = new WireMail(); $m->to($clientEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); // mark client as invited $event_table_row->client_invited = 1; $event->save('event_clients_list'); } } ?> But i have to use a variable in my emailbody.inc which i'm able to get in the table-loop.
      So i do the including of the body inside my loop. But this doesn't work anymore. Page sends out the emails but is unable to change the value of the checkbox.
      I get no errors!
      I'm using ProTable
      <?php // event ID fron url query $eventID = $input->get('eventID','int'); // get event-page $event = $pages->get($eventID); // config $fromEmail = $event->event_mail_from; $fromName = $event->event_mail_from_name; $emailSubject = $event->event_subject; // loop through table and send out emails foreach($event->event_clients_list as $event_table_row) { // get client page $clientPage = $event_table_row->client_name; // get client email $clientEmail = $clientPage->email; // email html body ob_start(); include('./_inc/emailbody.inc'); $emailBody = ob_get_clean(); // make event-page editable $event->of(false); // if client isn't invited yet (checkbox not checked) if($event_table_row->client_invited == '') { // send email $m = new WireMail(); $m->to($clientEmail); $m->from($fromEmail, $fromName); $m->subject($emailSubject); $m->bodyHTML($emailBody); $m->send(); // mark client as invited $event_table_row->client_invited = 1; $event->save('event_clients_list'); } } ?>  
    • By maba
      Hello,
      I need to import regularly - every 15 or 30 days - a big .xslx file into my PW installation.
      This file now has 14 columns, 5.000 rows and grows every month.
      I'll need to group, order and work with these data to:
      analyse User monthly costs analyse User costs per Asset ... User (real AD account) has to match with a PW user - I can't join to the domain - but as you can see I have some services users (start with sca_*) or no user at all. Those rows have to be assigned to a specific user, e.g. account100.
      And:
      I would like to be able to have a kind of diff function to compare User assets between this and last month (and so on) other request is to have a notification when something change for a User between actual and latest import First request: which is the best solution to store those data in your opinion? Page, Table, Repeater Matrix, ...?
      Those are very repetitive data and I think a page reference is better than to import all the data every time but I have to understand how to manage those "dynamic" groups of software (AccType Det), hardware (Asset), ... For example Price will be imported and not stored with the description because it could be change in the future and I'll not have any control on it.
      Thanks!
      User,OE,productNmr,AccType1,AccType Det,Count,Price (€),Sum,ASNA,CC,AccType Info,Asset,AccGroup,,,,,,,,,,,,,
    • By howdytom
      What is the best to way to structure my PW Template for long blogposts with repeating text paragraphs, images and custom code? I am looking for a flexible solution to add and rearrange text or images. A blogpost looks always different:
      --TEXT PARAGRAPH (CKEditor)
      --IMAGE
      --IMAGE
      --TEXT PARAGRAPH (CKEditor)
      --IMAGE
      --CUSTOM CODE FIELD
      --TEXT PARAGRAPH (CKEditor)
      Here's what I came up with so far...
      1. One approach could be using CKEditor along with ckeditor config.autoGrow. However I don't like the idea to add all content into one giant textfield and with one looooong  scrollbar.
      2. Repeater module seems to be the right choice. But text and image fields are always bundled within the repeater, even when no text field is required. Editing long post could be really confusing. 
      3. ProFields and Repeater Matrix looks like the right solution I am looking for. According to the ProFields description it is possible to add, combine, arrange different fields in one Repeater. Is that correct?
      Thank you for any help. 
    • By Tyssen
      I have a page that contains a single ProFields table field and I want to display the contents of the table on the front end and then for logged in users, they can edit certain columns in the table.
      What I have at the moment is
      $out = '<form action="'.$page->url.'" method="post" > <table class="table"> <tbody>'; $count = 1; foreach($page->fieldName as $row) : $out .= ' <tr> <td><input type="checkbox" name="fieldName_'.$count.'_columnName"></td> </tr>'; if($input->post->submit) : $page->of(false); $page->set('fieldName_'.$count.'_columnName', $sanitizer->text($input->post->{fieldName_'.$count.'_columnName})); $page->save(); endif; $count++; endforeach; $out .= ' </tbody> </table> <button class="button" type="submit">Save</button> </form>'; The two problems I have are:
      I get an error trying from $sanitizer->text($input->post->{fieldName_'.$count.'_columnName}), not sure how to make that dynamic.  If I change the above to just a static value, e.g. $page->set('fieldName_1_columnName', 'Testing') and save the form, it's not saving the values to the database. Where am I going wrong?
    • By ivineets
      Hi,
      Whenever I try to create a repeater field on my website, I get following error:
      General error: 3161 Storage engine MyISAM is disabled (Table creation is disallowed).
      If I still continue, it creates the field but doesn't allow storing any kind of data. How do I resolve this?  Is there any alternative to repeatable content that I can use?
       
      Thanks for your time.
       
       
×
×
  • Create New...