Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8240729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:35:25+00:00 2026-06-07T20:35:25+00:00

I’m still using 4.1 and I’m trying to center a form content on screen.

  • 0

I’m still using 4.1 and I’m trying to center a form content on screen.
When I add a new form it stays on the “left” of the screen.

I’ve tried to change form.html (temmplates/shared) adding a div with a style like this:

margin-left : 10%; margin-right : 10%; 

up next to the form tag and closing it at the bottom.

The form goes to the right but not centered at all.

Anyone has any clue to help with this ?

Here is a screenshot of a simple Form (it’s not basec on models)

form example

thanks
Alejandro

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T20:35:26+00:00Added an answer on June 7, 2026 at 8:35 pm

    Ok – i’ve gone to a default of atk4.2 to demonstrate.

    If you add a new page with defaults as follows

    <?php
       class page_test extends Page {
       function init() {
         parent::init();
         $p=$this;
    
         $f=$p->add('MVCForm')->setModel('Customer');
       } 
    }
    ?>
    

    I get the following and the fields extend across the whole width of the page.

    enter image description here

    This is because the default page template takes the whole width and is expected.

    In order to adjust the form, you can use view functionality so create a view under the /lib/View directory called Centre.php and put the following code in it

    <?php
    class View_Centre extends View {
       function init(){
          parent::init();
       }
    
       function defaultTemplate() {
         return array('view/centre');
       }
    
    }
    ?>
    

    Then create a new template for the view in yoursite/templates/default/view called centre.html and insert the following html code

    <div style='width:50%; margin: auto;'>
      <?$Content?>
    </div>
    

    and then in the page, we add the view first and the form into the view rather than straight into the page.

    <?php
      class page_test extends Page {
        function init() {
          parent::init();
          $p=$this;
    
          $v=$p->add('View_Centre');
          $f=$v->add('MVCForm')->setModel('Customer');
        } 
      }
     ?>
    

    and this results in the following web page

    enter image description here

    The base ATK4 form is itself a view which means you can style the form however you want so if you get for example use a different style of form such as the one described here you can do this by copying yoursite/atk4/atk4/templates/shared/form.html to yoursite/atk4/templates/shared.form.html and changing the second line from

     <?form?>
       <div id="<?$_name?>" class="atk-form <?$class?>" style="<?$style?>">
       <?$hint?>
       <form class="<?$form_internal_class?>" id="<?$form_name?>" name="<?$form_name?>" action="<?$form_action?>" method="POST" <?$enctype?>>
       <fieldset class="<?$fieldset?>">
    

    to

     <?form?>
       <div id="stylized>" class="myform <?$class?>" style="<?$style?>">
       <?$hint?>
       <form class="<?$form_internal_class?>" id="<?$form_name?>" name="<?$form_name?>" action="<?$form_action?>" method="POST" <?$enctype?>>
        <fieldset class="<?$fieldset?>">
    

    Create a new form.css file in yoursite/templates/default/css which contains the styling

    Copy yoursite/atk4/templates/shared/shared.html to yoursite/templates/shared/shared.html and add an extra tag

      <?$css_include?> 
    

    just above the existing

       <?$js_include?>
    

    and in Frontend.php, let every page find the new css file.

        $this->addLocation('templates',array(
                           'css'=>array(
                             'default/css',
                            ),
              ));
              $this->template->appendHTML('css_include','<link type="text/css" href="'.$this->api->locateURL('css','form.css').'" rel="stylesheet">');
    

    which results in a styled form like this

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.