nabo

Get values of options fieldtype

Recommended Posts

Hello

I can't get the title in other language than default

$type_materials = $fields->get('material_tipology');

foreach ($type_materials->type->getOptions($type_materials) as $type_material) {
echo $type_material->title;
}

this works but I get only default title in every language. 

Share this post


Link to post
Share on other sites

There's (I think) no direct method to access language specific properties yet, but you can do this:

<?php

$lang = $languages->get('name-of-your-language');
$langTitle = $type_material->get('title' . $lang->id);

Or, if you know the language id (e.g. 1060), you could do:

<?php

$langTitle = $type_material->title1060;

 

  • Like 1

Share this post


Link to post
Share on other sites

To get the options title in current user language use

$type_material->getTitle();

or enable outputformatting

$type_material->of(true);
$type_material->get('title');

 

  • 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.