Jump to content

Returning HTML not running PHP function


Adamhumbug
Go to solution Solved by Adamhumbug,

Recommended Posts

I had a function that had some html returned in it.

As i had to apply some conditions that would have needed me to duplicate the chunk of code, i have moved it into a function of its own that is called where i would have output the html.

The function returning the HTML is doing so:

function showAddNewItemPanel(){
    return <<<HTML
            <div class='card mb-4' id='addNewQuoteItems'>
                <div class='card-header'><strong>Add New Item</strong></div>
                <div class='card-body'>
                    <div class='p-3'>
                        <form method='post' class='row g-3' id='newItemForm'>
                            <div class='col-md-5'>
                                <label for='itemId' class='form-label'>Item Name</label>
                                <select type='text' class='form-control' id='itemId' name='itemId' disabled>
                                    <option value=''>Please Select...</option>
                                    <?= selectAllItemsBySection() ?>
                                </select>
                            </div>
                            <div class='col-md-1'>
                                <label for='quantity' class='form-label'>Quantity</label>
                                <input type='text' class='form-control text-center' id='quantity' name='quantity' disabled>
                            </div>
                            <div class='col-md-3'>
                                <label for='startDate' class='form-label'>Start Date</label>
                                <input type='date' class='form-control' id='startDate' name='startDate' disabled>
                            </div>
                            <div class='col-md-3'>
                                <label for='endDate' class='form-label'>End Date</label>
                                <input type='date' class='form-control' id='endDate' name='endDate' disabled>
                            </div>
                            <div class='col-md-12'>
                                <label for='notes' class='form-label'>Notes</label>
                                <textarea class='form-control' id='notes' name='notes' rows='3' disabled></textarea>
                            </div>
                            <hr>
                            <div class='col-md-5'>
                                <label for='pricePerItemDisplay' class='form-label'>Price Per Item</label>
                                <input type='text' class='form-control' id='pricePerItemDisplay' disabled>
                            </div>
                            <div class='col-md-4'>
                                <label for='chargableUnitsDisplay' class='form-label' id='chargableUnitsLabel'>Weeks</label>
                                <input type='text' class='form-control' id='chargableUnitsDisplay' name='chargableUnitsDisplay' disabled>
                            </div>
                            <div class='col-md-3'>
                                <label for='itemTotal' class='form-label'>Item Total</label>
                                <input type='text' class='form-control' id='itemTotal' name='itemTotal' disabled>
                            </div>
                            <div class='col-md-12'>
                                <div class='btn btn-primary' id='addNewItem' name='addNewItem' disabled>Save</div>
                            </div>
                            <input type='hidden' name='pricePerItem' id='pricePerItem'>
                            <input type='hidden' name='chargableUnits' id='chargableUnits'>
                            <input type='hidden' name='quoteTotal' id='quoteTotal'>


                        </form>
                    </div>
                </div>
            </div>
HTML;
}

The issue that i have is that the php function that is in there is now not showing its results and not creating the options for the select. - <?= selectAllItemsBySection() ?>

Is there something that i have ommitted here?

I have tried the method shown above and also returning not using heredoc.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.