Ticket #661 (closed enhancement: fixed)

Opened 3 years ago

Last modified 20 months ago

HtmlBefore and HtmlAfter are not honored in Render()

Reported by: VexedPanda Owned by:
Priority: important Milestone: 2.1
Component: QControls Version: 2.0 HEAD
Keywords: Cc:

Description (last modified by VexedPanda) (diff)

The appending of these elements should be built into all default render functions.

Attachments

Patch-661-HtmlBeforeAndAfter.patch Download (1.6 KB) - added by basilieus 2 years ago.

Change History

Changed 3 years ago by alex94040

  • status changed from new to infoneeded_new

Vexed- appending of HtmlBefore? and HtmlAfter? happens in QControl.class.php, not in any of the lower-level children that inherit from it. Why would we want to special-case QDataRepeaters this way?

Changed 3 years ago by VexedPanda

  • status changed from infoneeded_new to new

The QDataRepeater already special cases them, so I didn't dig into QControl.class.php.

I don't have time to test in 2.0 this week, but this should be some reproduce code. If it works in 2.0, maybe mark as invalid. :)

In Form_Create:

$this->dtrRepeater = new QDataRepeater($this);
$this->dtrRepeater->DataSource = array(1);
$this->dtrRepeater->HtmlAfter = "This should appear";
echo $this->dtrRepeater->Render(false);

$this->dtrRepeater1 = new QDataRepeater($this);
$this->dtrRepeater1->DataSource = array();
$this->dtrRepeater1->HtmlAfter = "This should still appear";
echo $this->dtrRepeater1->Render(false);

Changed 3 years ago by VexedPanda

  • status changed from new to in_QA

Changed 3 years ago by alex94040

The example you're referring to (conceptually) works just fine in 2.0.2. You can't do a Render() call in Form_Create; moreover the Render call you're referring to most likely is RenderWithName?, as HtmlBefore? and HtmlAfter? are only relevant there.

Suggesting resolve as Invalid.

So here's the code:

sample.php:

	require('includes/configuration/prepend.inc.php');

	class SampleForm extends QForm {
		protected $dtrRepeater;
				protected $dtrRepeater1;

		protected function Form_Create() {
			$this->dtrRepeater = new QDataRepeater($this);

			$this->dtrRepeater->HtmlAfter = "This should appear";
			$this->dtrRepeater->DataSource = array(1);
			
			$this->dtrRepeater1 = new QDataRepeater($this);
			$this->dtrRepeater1->DataSource = array();
			$this->dtrRepeater1->HtmlAfter = "This should still appear";
		}
		
		protected function btnButton_Click($strFormId, $strControlId, $strParameter) {
			$this->lblMessage->Text = 'Hello, World!';
		}
	}

	SampleForm::Run('SampleForm');

sample.tpl.php:

<?php $this->RenderBegin(); ?>
	<? $this->dtrRepeater->RenderWithName(); $this->dtrRepeater1->RenderWithName(); ?>
<?php $this->RenderEnd(); ?>

Changed 3 years ago by alex94040

  • status changed from in_QA to infoneeded

Changed 3 years ago by VexedPanda

  • status changed from infoneeded to assigned

Try with just Render, since I'm not doing a RenderWithName? in my case.

Changed 3 years ago by VexedPanda

  • status changed from assigned to in_QA

Perhaps it does make sense to have Render in change of HtmlBefore? and After, and not make the controls aware of it though. This should still be a change in QDataRepeater then, to remove the old code.

Changed 3 years ago by alex94040

The Render() call does not produce the HtmlBefore/After? for either of the data repeaters. Vexed, I always thought that HtmlBefore/After? properties were really created for user-level customization - and custom Render() methods, not the built-in Render() stuff. I might be really confused, though.

Changed 3 years ago by VexedPanda

  • status changed from in_QA to assigned
  • description modified (diff)
  • summary changed from HtmlBefore and HtmlAfter are not honored in QDataRepeaters with empty data sources to HtmlBefore and HtmlAfter are not honored in Render()
  • version changed from 1.0.3 Legacy Maintenance to 2.0 HEAD
  • milestone changed from 1.0 and Up to 2.0.3
  • type changed from defect to enhancement

Ok, I must have been looking at some of my custom code, because yeah, I don't see any HtmlAfter/Before? code in the core QDataRepeater. So I apologize for getting this all confused. I'm changing this to a feature request unrelated to data repeaters. :P

If these parameters are part of the core controls (which they are) I think the core render methods need to accommodate them.

Changed 2 years ago by basilieus

Changed 2 years ago by basilieus

Let me know if this is what you had in mind Vexed.

Changed 2 years ago by basilieus

  • status changed from assigned to in_QA

Changed 20 months ago by vakopian

  • status changed from in_QA to closed
  • resolution set to fixed

(In [1311]) code by basilieus, review by vakopian. Fixes #661

Note: See TracTickets for help on using tickets.