Page 1 of 1

Header caption in ListOptions_Load

Posted: Tue Sep 17, 2024 1:23 am
by ericcole

Hi.

I'm using right now the last version of PHPMaker: 2024.15.

I want to add custom columnt to my lists, but the new columns won't show the headers. I've tryed using the example and nothing:

function ListOptions_Load() {
    $item = &$this->ListOptions->add("new");
    $item->Header = "MyCaption"; // Set the column header (for List page)
    //$item->OnLeft = true; // Link on left
    //$item->moveTo(0); // Move the column to the specified index
}

And:

function ListOptions_Rendered()
{
	// Example: 
	$this->ListOptions->Items["new"]->Body = "xxx";
}

But the Header is empty. It worked in previous PHPMaker, likes 2020.

Thanks.


Re: Bug?: Header caption in ListOptions_Load doen't work PHPMKR 24.15

Posted: Tue Sep 17, 2024 7:24 am
by sangnandar

You can var_dump((array)$this->ListOptions) or var_dump((array)CurrentPage()->ListOptions) in Page_Render() to see the object for the header. Perhaps it's no longer $item->Header.


Re: Bug?: Header caption in ListOptions_Load doen't work PHPMKR 24.15

Posted: Wed Sep 18, 2024 4:47 am
by ericcole

I have tried. I can put a button, link or an image to Header; but only text doen't work.
The same happens with the body. Only text doesn't work. I have tried with a, p, span, b, i etc. tags and nothing.

    public function listOptionsLoad()
    {
        $opt = &$this->ListOptions->add("new");
        $opt->Header = '<button type="submit">Text</button>'; // Set the column header (for List page)
        $opt->OnLeft = false; // Link on left
        $this->ListOptions->Items["new"]->ShowInDropDown = FALSE;
    }

    public function listOptionsRendered()
    {
        // Example:
        //$this->ListOptions["new"]->Body = "xxx";
        $this->ListOptions->Items["new"]->Body = '<button type="submit">MoreText</button>';
    }

Thank you.


Re: Header caption in ListOptions_Load

Posted: Wed Sep 18, 2024 5:40 am
by sangnandar

I tried this code and it works fine. I suggest to check your code if the header is overridden somewhere else.

public function listOptionsLoad()
{
    // Example:
    $opt = &$this->ListOptions->add("new");
    $opt->Header = "I'm header";
    $opt->OnLeft = true; // Link on left
    $opt->moveTo(0); // Move to first column
}

public function listOptionsRendered()
{
  $this->ListOptions->Items["new"]->Body = '<button type="submit">MoreText</button>';
}

It occurs to me that you might work with button-group, of which ListOptions->Items[] are wrapped in a dropdown button.
If that's the case, you have to set

$opt->ShowInButtonGroup = false;

in addition of

$opt->ShowInDropDown = false;

Re: Header caption in ListOptions_Load

Posted: Thu Sep 19, 2024 4:32 am
by ericcole

It works! Thank you!

We need both of them:

        $opt->ShowInButtonGroup = false;
        $opt->ShowInDropDown = false;

It works the header and the text in the body.

Thanks a lot!