Adamhumbug Posted September 3, 2023 Share Posted September 3, 2023 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. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 3, 2023 Share Posted September 3, 2023 When you view the page source, what have you got where you expect the options of the select? Quote Link to comment Share on other sites More sharing options...
Adamhumbug Posted September 3, 2023 Author Share Posted September 3, 2023 1 minute ago, Barand said: When you view the page source, what have you got where you expect the options of the select? ahh - strangely it is commented out. Quote Link to comment Share on other sites More sharing options...
Adamhumbug Posted September 3, 2023 Author Share Posted September 3, 2023 <select type="text" class="form-control" id="itemId" name="itemId"> <option value="">Please Select...</option> <!--?= selectAllItemsBySection() ?--> </select> Quote Link to comment Share on other sites More sharing options...
Solution Adamhumbug Posted September 3, 2023 Author Solution Share Posted September 3, 2023 (edited) fixed with ".selectAllItemsBySection()." Thanks Barry for that pointer. Edited September 3, 2023 by Adamhumbug Quote Link to comment Share on other sites More sharing options...
Barand Posted September 3, 2023 Share Posted September 3, 2023 You can't embed a function call in a string. You need to concatenate EG echo "Today is " . date('l'); not echo "Today is date('l')"; Quote Link to comment Share on other sites More sharing options...
Barand Posted September 3, 2023 Share Posted September 3, 2023 You beat me to it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.