Sonia Margollé

Select field inside a profields Table

Recommended Posts

I have a problem and I don't understand. I have a profield table with different fields and a select field.
I did like it's instructed and put "value=label".

But when I'm trying to output the select field with var_dump (to debug),  it's indicated that the field is a string that contains the value.
Why is it a string ?  when I try  myselectfield->value  or label or title I have an error saying I'm trying to get a property on a non-object ...

Anyone ? 

Share this post


Link to post
Share on other sites

Select with return a string. Select Multiple will return an array.

The label or title is part of the field definition, not the stored value for that field for the selected row.

Does that make sense?

Share this post


Link to post
Share on other sites

They are different beasts, but you can get the label like this:

$page->table_name->getLabel('select_field_name');

 

  • Like 2

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By mike62
      I'm trying to echo a field from another page, in my footer. I have a Website Settings page (id 1006) with several fields for general site settings, like store hours (field is named store_hours). In the footer, I have this:
      <?php $settingsPage = $pages->get(1006); echo $settingsPage->store_hours; ?> Shouldn't that output the contents of that field? Right now it's printing a "0" (zero) on the page.
      Elsewhere in the same footer template file, I have this code and it works fine:
      <?php $homepage = $pages->get(1); echo $homepage->body; ?> Does it have anything to do with the fact that the field is organized into one of these tabs, at the top of the page editor?
      (disclaimer: I'm new to PW, and have inherited this site from another developer; that's why I don't know how or why some of this stuff is set up the way it is).
      Thanks!

    • By Robin S
      In response to a wishlist request...
      Field Save + Add New
      Adds a "Save + Add New" button when editing a field.

      Usage
      Install the Field Save + Add New module.
      When editing a field, click "Save + Add New" if you want to save the current field and start the process of adding a new field.
      Note: The button will not redirect you to "Add New" if you are performing some special action such as duplicating a field or adding a field to a template.
       
      https://github.com/Toutouwai/FieldSaveAdd/
    • By szabesz
      Hi,
      I moved a site to a new home and ran into a "strange" issue:

      No field is added. I have no error message "anywhere", not in the console, no PHP, not in server logs either.
      The strange thing is that I can Duplicate fields: Setup > Fields > Actions > Duplicate/clone this field?
      Meaning it is just the "Add New Field" which does nothing. I can also create pages.
      Also,  "Add New Field" does work in local development environment (same site and "same state", of course), it is just the new server environment which is problematic.
      Any ideas for troubleshooting? Thanks in advance
    • By Alex CA
      I was just looking at this module Profields
      It states that  except  Repeater Matrix ProField ,everything works with Processwire 2.6+. 
      I am currently using Processwire 2.7.2 and I primarily wan to make use of Table and Autolinks. Has anyone using Processwire2.7 faced any issue with this module?
      I am relatively new to Processwire and I do not want to end up buying a module which could have compatibility issues. Thanks
    • By joelplambeck
      Hello everyone,
      My Website works just fine beside the one field which behaves strangely and I can't figure out why.
      I have a template called "main-subpage" which I use for most subpages. All of them have a header and on every other Page it works just fine.
      But on the one page it displays the first few letters random and sometimes the last ones corectly, sometimes the last ones are wrong as well. What iritates me is that this is only on the one Page and all the other pages with the same template don't have that issue. The rest of the page is displayed just fine.
      I tried different content in the field but it doesnt seem to help anything.
       
      Code in the template:
      <h1> <?php echo $page->header | $page->title; ?> </h1> on the page it should display: "Das Konzept des ZiSMed" but what I see is (attachement):
       
      Thank you for your help!
      display.tiff