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 chrizz
      I was wondering if there's an easy way to validate if a title is a valid value for a FieldtypeOptions field. 
      I have created a field with different status values where only a single value can be selected:
       
      1=done 2=planned 3=error Now I am going to update the page which includes this field which works fine so far - but: I I am using any other string than the defined options it stores a blank value. To avoid this I am trying to validate the input before. Something like getAllOptionsForField > in_array() etc would work but maybe there's a build-in method I am currently missing? 
      Long story short: how would you validate if the given string is a valid option for a field?
      as usual: Thanks
       
       
    • By louisstephens
      So I have been creating an internal web app over the last couple months, and am finally on the last piece of the puzzle, customizable forms. I thought I could just create a view basic forms and use a select option to let them select the form, and my template file could just output the form based on their selection. Easy enough. However, I have since ran into a slight head scratcher. Not all the forms are the same and they might vary greatly between each other. 
      Has anyone done something similar to this? In an ideal world, I would use form builder, but I really dont want them to have access to it. They are currently constrained to a few pages in the backend, which is why I was trying to think of a way for them to select a few fields (like from a page select), and then render the selections on the front end based on what was selected.
    • By rareyush
      I added a field type 'page reference' using checkboxes knows as services.
      now i want to display the pages according to service.
      I can display all services list but when i click on any services then I can see whole code of site 
       
      any idea where i am wrong
      ?
      main cate1 subcate1 subcate2 cate2 subcate1 subcate2 services first-service second services  
       
      these services is being used as a page reference  in subcate1, subcate2 templates.
       
      and in the navbar when i click on services and then when i click on any of the following service then i can see whole source code of my site.
    • By benbyf
      Hello, having trouble getting PW to save my user or field in cron hook.
      It seems to report the same field info each time unchanged. It should be counting down in seconds.
      public function init() { // set to every30Seconds in settings $this->defaultInterval = $this->cron_check; // add hooks to CRON $this->addHookAfter("LazyCron::{$this->defaultInterval}", $this, 'checkUserSubscription'); } public function ___checkUserSubscription(HookEvent $e){ // seconds since last lazycron $seconds = $e->arguments[0]; $log = wire('log'); $field = $this->exclusiveRole; // users with specific role and field $users = $this->users->find("roles=$field"); foreach ($users as $user) { // get stored time $currentTime = $user->get($this->fieldName); // if time not null if($currentTime){ // evalute stored time minus time past $resultTime = intval($currentTime) - intval($seconds); $log->message("result ".$resultTime); // save user page $user->set($this->fieldName, $resultTime); $this->users->save($user); } } }  
    • By rareyush
      I am trying too create a custom field where when user select to create a category 2 text area shows where one title of the category goes & another for some content.
      Like in a picture I want 2 text areas when I click on create new