Formatting Controls

Login or register to post comments
14 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

I'm getting the hang of things pretty well now, however I have one major hurdle to overcome, before I can begin to produce anything functional.

Is there a tutorial that explains how to overcome the formatting of QCubed. I've researched the code and Render and RenderWithName cause all data (for edit) to be listed down the left side of the screen. Is there a tutorial that explains how to render controls in a more formatted fashion? I'm well aware of using CSS for such formatting, but I have not been able to overcome the CSS inserted by the renderer.

Help. This is for 1.1.

alex94040's picture
Offline
Joined: 11/06/2008

LaCeja, what is Render() outputting that you'd like to modify / remove?

LaCeja's picture
Offline
Joined: 11/04/2009

I want to change for formatting. Render() simply lists everything down the left side of the page. Should I be using QBlockControls?

I just need to be able to use CSS to format each page. This is a business application with lots of input and label controls, which need to be organized into groups. It's very transaction oriented, rather than distributing blocks of text. For example, I need to present for user input:

Customer No: _________ Name: ____________ Acct Type: ___

Not:

Customer No: _________

Name: _________

Acct Type: _________

alex94040's picture
Offline
Joined: 11/06/2008

You should use the .tpl files to customize the overall layout of your page. That's what the tpl is for. You can place controls inside HTML tables, do whatever you want with that HTML, really.

To add CSS style to controls: use AddCssClass() method. It's discussed in detail in the Debugging screencast.

Also, review the 'calculator with design' example on the Examples site.

akrohn's picture
Offline
Joined: 11/14/2008

Or you can simply write your own render methods. So did I. RenderWithName() itself is an example of customizations of the render methods. Look there :)

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks, I appreciate the guidance. I'll look into both.

LaCeja's picture
Offline
Joined: 11/04/2009

It does indeed seem that RenderWithName must be overridden in order to format the page. AddCssClass() works great to set appearance characteristics of any given control, however it cannot affect placement of a control on the page. This is because RenderWithName() appears to put each control into its own . I'm now testing out a plugin I discovered called populate, which allows you to create your form in plain HTML format and the plugin will populate it with your data. I'll report later on how it works, if at all. It was created for another framework, so I'm not sure how it will work in QCubed.

alex94040's picture
Offline
Joined: 11/06/2008

LaCeja - have you experimented with .tpl files? You can place the control anywhere you want on a page... It's just a matter of editing the .tpl file.

I'm guessing I'm misunderstanding what you're trying to do all along... What exactly do you mean by "[i want to] affect placement of a control on the page... RenderWithName() appears to put each control into its own.."

LaCeja's picture
Offline
Joined: 11/04/2009

Alex, going back to my original example, when I render each control, for example, RenderWithName(userid); and then RenderWithName(username); they will be rendered as:

User ID: 1



User Name: John Doe

What "I want" is something like this, with both controls rendered on the same line:

User ID: 1 User Name: John Doe

I've looked at the code for RenderWithName and it specifically creates div's for each, which forces each control to be rendered on a separate line.

scottux's picture
Offline
Joined: 11/07/2008

You could do .renderWithName { display:inline; } in your CSS if you want every control to be rendered inline.

LaCeja's picture
Offline
Joined: 11/04/2009

RenderOutput already does that.

alex94040's picture
Offline
Joined: 11/06/2008

Like I said in the past, look at .tpl files, and use Render().

To achieve what you wanted in the example above, put this into the .tpl file:

User ID: <? $this->lblUserID->Render() ?>. User name: <? $this->lblUserName->Render() ?>.

LaCeja's picture
Offline
Joined: 11/04/2009

Thank you! I had not tried using simply Render(). I had been using only RenderWithName. This works out fine. I just created my own label control for each input control and it all works great. I'll just create a separate label control to display any errors and I'm good to go.

Thanks again!

Offline
Joined: 03/31/2008

The QControl.class.php file is _meant_ to be modified. You can create any custom render output you want, simply by creating new functions such as RenderMyWay(). RenderWithName is meant to be inspiration on some things you can do around the control.

LaCeja's picture
Offline
Joined: 11/04/2009

So far I've been able to get around everything by simply using Render() and by using AddCssClass. However, I've got another problem, but I'll open a new topic for it. However, it's very good to know QControl was meant to be modified. In many cases, it may make for much cleaner code.

Thanks.